package graph;
import java.awt.*;
import javax.swing.*;

import graph.color.*;
import graph.element.Graph;
import graph.element.shape.TypeForm;
import graph.color.Color;
import data.Data;
@SuppressWarnings("serial")
public class GraphPanel extends JPanel {
	public Graphics g;
	public Data data;
    protected final static int PAD = 20;
    final int SPACE = 5;
    public Graph graph;
    
    public TypeForm t = TypeForm.Circle;
    public boolean b = false;
    public Color c = (Color) new Warm();
    
 
    public GraphPanel(Data data) {
    	this.setBackground(java.awt.Color.WHITE);
    	this.data = data;
    }
    public Graphics getG() {
    	return g;
    }

    protected void paintComponent(Graphics g) {
    	this.g = g;
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        Font font = new Font("Arial", Font.PLAIN, 10);
        g2.setFont(font);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        try {
        	this.graph = new Graph(this, PAD, PAD, data, t, b, c);
        	this.graph.draw();
        	this.setPreferredSize(new Dimension(this.graph.getWidth(), this.graph.getHeight()));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
		}
    }
    
    public void modifierParam(Data data, TypeForm t, boolean b, Color c) {
    	this.data = data;
    	this.t = t;
    	this.b = b;
    	this.c = c;
    }
}